#ifndef MTV_SERVICE_DEF_H
#define MTV_SERVICE_DEF_H

/*******************************************************************************
Copyright (C), 2008, Borqs Tech. Co., Ltd.
File Name:
    mtvservice_def.h
Description:
    MobileTV MBBMS service related data structure defintion
History:
    Date          Author                         Comments
    -----------   ---------------------------    --------------------
    18-Jun-2008   song.bi@borqs.com              Created
*******************************************************************************/


#if __GNUC__ > 3 || _MSC_VER > 1020
#pragma once
#endif

#ifndef __cplusplus
#error this header requires C++ compiler
#endif

#include "mtv_config.h"

#define MBBMS_VERSION 250
// ----------------------------------------------------------------------------------------
// Service Guide related definition
// ----------------------------------------------------------------------------------------

// ----------------------------------------------------------------------------------------
// SGDD related definition
// ----------------------------------------------------------------------------------------
struct SGDDBrief
{
    SGDDBrief();
    virtual ~SGDDBrief();

    virtual void display(int indent) const;

    string id;
    int version;

    unsigned int BSMSelector_id;
    string WelcomeInformation;
};



struct BiLinker
{
    BiLinker();
    BiLinker(BiLinker* origin);

    virtual ~BiLinker();
    virtual void display(int indent) const;
    virtual void displayLinker(int indent);

    void operator delete(void *linker);

    BiLinker * prev;
    BiLinker * next;
};

struct StringSet: BiLinker
{
    StringSet(string src);
    StringSet(StringSet *origin, string src);

    virtual ~StringSet();
    virtual void display(int indent) const;

    string data;
};

struct Sequence: BiLinker
{
    Sequence();
    Sequence(const string sgid);

    virtual ~Sequence();

    Sequence * add(Sequence* header);

    virtual int compareTo(Sequence* origin);
    virtual int compare(string id0, string id1);
    virtual Sequence* getheader();

    string id;
};

struct MBBMS_Extension: BiLinker
{
    MBBMS_Extension(MBBMS_Extension* origin);
    virtual ~MBBMS_Extension();

    virtual void display(int indent) const;

    string url;
    string Description;
};

struct PreviewDataBrief: Sequence
{
    PreviewDataBrief(const string sgid);

    virtual ~PreviewDataBrief();
    virtual void display(int indent) const;

    unsigned char usage;
    string Text;

    string path;
};

struct MBBMS_Service: Sequence
{
    virtual ~MBBMS_Service();
    virtual void display(int indent) const;

    int version;
    string globalServiceID;
    int weight;

#if MBBMS_VERSION >= 100 && MBBMS_VERSION < 200     // A Version
    bool serviceContentProtection;
#elif MBBMS_VERSION >= 200 && MBBMS_VERSION < 300   // B Version
    bool forfree;
#endif

    string ServiceType;
    string Name;
    string Description;
    string Genre;

#if MBBMS_VERSION >= 200 && MBBMS_VERSION < 300 // B Version
    string ServiceProvider;
//      string ServiceLanguage;
    string CADescriptor;
#endif

    MBBMS_Extension *extension;
    PreviewDataBrief *previewdata;
};

struct ServiceBrief: Sequence
{
    ServiceBrief(const string sgid);
    virtual ~ServiceBrief();

    virtual void display(int indent) const;
    virtual int compareTo(Sequence* origin);

    string globalServiceID;

#if MBBMS_VERSION >= 100 && MBBMS_VERSION < 200     // A Version
    bool serviceContentProtection;
#elif MBBMS_VERSION >= 200 && MBBMS_VERSION < 300   // B Version
    bool forfree;
    bool isEncrypted;
#endif
    bool isSubscribed;
//      bool isServiceKeyExist;

    string ServiceType;
    string Name;

    PreviewDataBrief *previewdata;
};

struct MBBMS_Content: Sequence
{
    virtual ~MBBMS_Content();
    virtual void display(int indent) const;

    int version;
    string globalContentID;

#if MBBMS_VERSION >= 200 && MBBMS_VERSION < 300 // B Version
    bool forfree;
    bool live;
    bool repeat;
#endif

    string ServiceReferenceidRef;

    string Name;
    string Description;
    string StartTime;
    string EndTime;
    string Length;
    string Genre;

#if MBBMS_VERSION >= 200 && MBBMS_VERSION < 300 // B Version
    string Keyword;
    string ContentClass;
    string AudioLanguage;
    string TextLanguage;
    string CADescriptor;
#endif

    MBBMS_Extension *extension;
    PreviewDataBrief *previewdata;
};

struct ContentBrief: Sequence
{
    ContentBrief(const string sgid);
    virtual ~ContentBrief();

    virtual void display(int indent) const;
    virtual int compareTo(Sequence* origin);

#if MBBMS_VERSION >= 200 && MBBMS_VERSION < 300 // B Version
    bool forfree;
    bool live;
    bool repeat;
#endif

    string globalContentID;
    string ServiceReferenceidRef;

    string Name;
    string StartTime;
    string EndTime;

    bool isSubscribed;

//      ServiceBrief *service;
};

struct MBBMS_PurchaseChannel: Sequence
{
    MBBMS_PurchaseChannel(const string sgid);

    virtual ~MBBMS_PurchaseChannel();
    virtual void display(int indent) const;

    string Name;

    string Description;
    string PurchaseURL;
};

struct PurchaseItemBrief: Sequence
{
    PurchaseItemBrief(const string sgid);

    virtual ~PurchaseItemBrief();
    virtual void display(int indent) const;

    string globalPurchaseItemID; // For purchase.

    string Name;

    unsigned char subscriptionType; //

    string currency;    // For example: RMB
    string MonetaryPrice;   // Price

    bool isSubscribed;

    ServiceBrief *service;
    ContentBrief *content;
};

struct AccessBrief: Sequence
{
    AccessBrief();
    AccessBrief(const string sgid);

    virtual ~AccessBrief();
    virtual void display(int indent) const;

    string service_ID;
    bool isProtected;
    bool isSubscribed;
    bool isServiceKeyExist;
    string PermissionsIssuerURI;
    string protectionKeyID;
    unsigned int EncryptionType;
    unsigned int BSMSelector_id;
    unsigned char CMMB_frequencyNo;
    unsigned int CMMB_serviceID;
    string sdp;
};

struct MBBMS_SelectChoice: BiLinker
{
    MBBMS_SelectChoice();
    MBBMS_SelectChoice(MBBMS_SelectChoice *origin);

    virtual ~MBBMS_SelectChoice();
    virtual void display(int indent) const;

    string smsURI;
    StringSet *choicetext;
};

struct MBBMS_SMSTemplate: BiLinker
{
    MBBMS_SMSTemplate();
    MBBMS_SMSTemplate(MBBMS_SMSTemplate *origin);

    virtual ~MBBMS_SMSTemplate();
    virtual void display(int indent) const;

    unsigned int relativePreference;

    string Description;

    MBBMS_SelectChoice *selectchoice;
};

struct MediaObject: BiLinker
{
    MediaObject();
    MediaObject(MediaObject *origin);

    virtual ~MediaObject();
    virtual void display(int indent) const;

    MediaObject* getheader();

    string contentLocation;
    string contentType;

    bool start;
};

struct MBBMS_MediaObjectSet: BiLinker
{
    MBBMS_MediaObjectSet();
    MBBMS_MediaObjectSet(MBBMS_MediaObjectSet *origin);

    virtual ~MBBMS_MediaObjectSet();
    virtual void display(int indent) const;

    unsigned int relativePreference;
    string contentType;

    string Description;

    MediaObject *mediaobject;
};

struct MBBMS_MediaObjectGroup: Sequence
{
    MBBMS_MediaObjectGroup(const string sgid);

    virtual ~MBBMS_MediaObjectGroup();
    virtual void display(int indent) const;

    bool startMediaFlag;

    // ActionDescriptor
    unsigned int inputAllowedTime;
    string onTimeOutPointer;
    string onActionPointer;

    // Weblink
    unsigned int relativePreference;
    string webURL;
    string Description;

    string AlternativeText;

    MBBMS_MediaObjectSet *mediaobjectset;
    MBBMS_SMSTemplate *smstemplate;
};


#endif                          // end of #ifndef BROADCAST_SERVICE_H_INCL
